package philbot;

/**
 * Basic class for evaluating the strength of a position
 */
public abstract class Evaluator {
	/**
	 * This class is used by the position to communicate with the evaluator
	 * @author philip
	 */
	public static class Values{
		/**
		 * A field representing the value of the ball location.
		 */
		public int lScore = 0;
		/**
		 * A field representing how far the ball can jump using only forward jumps
		 */
		public int jScore = 0;
		/**
		 * is this position a win for the up player
		 */
		public boolean aWin = false;
		/**
		 * is this position a win for the down player
		 */
		public boolean bWin = false;
		/**
		 * who's turn is it
		 */
		public boolean side = true;
	}
	/**
	 * 
	 * @param v the values passed in
	 * @return the evaluated score
	 */
	public abstract int eval(Evaluator.Values v);
	/**
	 * @return a default evaluator using only the location of the ball and the side to play
	 */
	public static Evaluator defaultEvaluator(){
		return new Evaluator(){ 
			public int eval(Evaluator.Values v){
				int flip = -1;
				if(v.side)
					flip = 1;
				return flip*(v.lScore);
			}
		};
	}
}
